package controllers;

import play.*;
import play.data.validation.Required;
import play.data.validation.Validation;
import play.mvc.*;

import java.awt.Checkbox;
import java.util.*;

import org.apache.commons.mail.EmailException;

import models.*;
import play.db.jpa.*;

/**
 * MarkIdeaAsDuplicate Controller that handles the request and the
 * confirm/reject that idea is duplicate and it is shown on the view.
 * 
 * @author Nada Hassan
 * 
 */
public class MarkIdeaAsDuplicate extends Controller {

	public static Long ideaId1;

	/**
	 * ConfirmIdeaAsDuplicate method the organiser sends a reply to the idea
	 * developer confirming him that the request that the idea is a duplicate is
	 * approved with the link to the page of the duplicate idea that is shown in
	 * the html file.
	 * 
	 * @throws EmailException
	 * @author Nada Hassan
	 */
	public static void ConfirmIdeaAsDuplicate() {

		render();
	}

	/**
	 * RejectIdeaAsDuplicate method the organizer sends a reply to the idea
	 * developer rejecting his request to mark or consider idea as duplicate.
	 * 
	 * @param ideaDeveloper
	 *            idea developer by which rejection mail will be sent.
	 * @param organizer
	 *            organizer that sends the reject mail to the idea developer.
	 * @throws EmailException
	 * @author Nada Hassan
	 */
	public static void RejectIdeaAsDuplicate(User Organizer, User IdeaDeveloper)
			throws EmailException {
		Email rejectMail = new Email("bob@gmail.com",
				"nada.hassan.90@gmail.com", "Request Rejected",
				"The request of marking idea is duplicate is rejected");
		rejectMail.sendEmail();
		render(rejectMail);
	}
//
//	/**
//	 * MarkAsDuplicate method takes tow ideas and check if there body or content
//	 * was similar and if it is similar the title of duplicate idea is added to
//	 * the original idea and the duplicate idea will be marked as duplicate in
//	 * the MarkAsDuplicate html file.
//	 * 
//	 * @param title
//	 *            title of the idea.
//	 * @param body
//	 *            body of the idea.
//	 * @throws EmailException
//	 * @Author Nada Hassan
//	 */
//
//	public static void MarkAsDuplicate(String title, String body)
//			throws EmailException {
//		Email duplicateRequest = new Email("bob@gmail.com",
//				"nada.hassan.90@gmail.com", "Request Idea is Duplicate",
//				"I think that this Idea is duplicate...Please Check it");
//		Idea originalIdea = new Idea("Sports in Egypt", "Bad");
//		Idea duplicateIdea = new Idea("Sports in Egypt", "Bad");
//		originalIdea.save();
//		duplicateIdea.save();
//		if (originalIdea.equals(duplicateIdea))
//			duplicateRequest.sendEmail();
//		render(duplicateRequest, originalIdea, duplicateIdea);
//
//	}

}
